<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
    String queryString = request.getQueryString() == null ? "" : request.getQueryString().replaceAll("(\\&?lang\\=[a-zA-Z]{2}\\_[a-zA-Z]{2})|(lang\\=[a-zA-Z]{2}\\_[a-zA-Z]{2}\\&?)", "");
    String lang = request.getParameter("lang");
    String hspId= request.getParameter("hospitalId");
    if (lang != null) {
        session.setAttribute("locale", lang);
    } else if (session.getAttribute("locale") == null) {
        session.setAttribute("locale", request.getLocale().toString());
    }
%>
<!DOCTYPE html>
<html lang="zh">
<c:if test="${'zh_CN'.equals(sessionScope.locale)}">
    <fmt:setLocale value="zh_CN"/>
</c:if>
<c:if test="${sessionScope.locale.indexOf('en') != -1}">
    <fmt:setLocale value="en_US"/>
</c:if>
<fmt:setBundle basename="charts" var="charts"/>
<fmt:bundle basename="charts">
    <head>
        <meta charset="utf-8"/>
            <%-- rem.js --%>
        <script src="<%=basePath%>/js/rem.js"></script>
        <title>医疗设备系统</title>
        <link rel="shortcut icon" href="<%=basePath%>/images/favicon.ico">
        <link href="<%=basePath%>/plugins/charts/css/global.css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=basePath%>/css/font-awesome.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/iziModal/css/iziModal.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/select2/select2.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/iCheck/all.css">
        <link href="<%=basePath%>/plugins/charts/css/select2-my.css" rel="stylesheet"/>
        <link href="<%=basePath%>/plugins/charts/css/style.css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=basePath%>/plugins/flavr/flavr.css">
    </head>
    <body>
    <div id="container">
            <%--顶部选项--%>
        <div class="head-container">
            <div class="head">
                <div class="fl global_area">
                    <i class="fa fa-arrow-left fl" onclick="javascript:history.go(-1);"></i>
                    <div class="fl" id="language">
                        <div class="language">
                            <c:choose>
                                <c:when test="${'zh_CN'.equals(sessionScope.locale)}">简体中文</c:when>
                                <c:when test="${sessionScope.locale.indexOf('en') != -1}">English</c:when>
                                <c:otherwise>简体中文</c:otherwise>
                            </c:choose>
                        </div>
                        <ul class="hide">
                            <li><a href="?<%=queryString%>&lang=zh_CN">简体中文</a></li>
                            <li><a href="?<%=queryString%>&lang=en_US">English</a></li>
                        </ul>
                    </div>
                    <ul class="global">
                        <li><a id="btn1"><fmt:message key="share.title.zl"/></a></li>
                        <li><a id="btn2" class="on"><span class="page" page-hospital="department-index"><fmt:message
                                key="share.title.fx"/></span>-<span class="page"
                                                                    page-hospital="model-index"><fmt:message
                                key="share.title.sbxh"/></span>-<fmt:message key="share.title.yyxl"/></a>
                        </li>
                        <li><a id="btn5"><img src="<%=basePath%>/plugins/charts/images/search.png"></a></li>
                        <li><a id="btn6" onclick="reset()"><img
                                src="<%=basePath%>/plugins/charts/images/reset.png"></a></li>
                        <li><a id="btn7" onclick="logout()" title="<fmt:message key="share.title.tcdl"/>"><img src="<%=basePath%>/plugins/charts/images/logout.png"></a></li>
                    </ul>
                </div>
                <div class="clear"></div>
            </div>
        </div>
            <%--筛选条件--%>
        <jsp:include page="choose.jsp"></jsp:include>

        <div class="content" style="display:flex;flex-direction:column;justify-content:flex-start;">
                <%-- 总量统计 --%>
            <div class="totle">
                    <%-- 设备类型 --%>
                <div class="frame frame1" style="width:24%;">
                    <div class="border">
                        <div class="detail fl">
                            <p class="title"><em class="spanTitle active" id="title1"><fmt:message
                                    key="share.title.yyks"/></em><span
                                    id="yoy0" style="font-size:12px;color:#e68b36;text-decoration:none;"></span></p>
                            <p class="sum"><fmt:message key="performance.overview.zsr"/>: <em id="count1-2"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wysr"/>：<em id="yoy1-2"> </em></p>
                        </div>
                        <div class="chart fr chart-text">
                            <p class="sum"><fmt:message key="performance.overview.szb"/>：<em id="count1-1"></em></p>
                            <p class="sum"><fmt:message key="share.overview.kssl"/>：<em id="yoy1-1"></em> <fmt:message
                                    key="share.unit.ge"/></p>
                            <p class="line"></p>
                            <p class="sum"><fmt:message key="performance.overview.zzc"/>：<em id="count1-3"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wyzc"/>：<em id="count1-4"></em></p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                    <%-- 大维修 --%>
                <div class="frame" style="width:23%;">
                    <div class="border">
                        <div class="detail fl">
                            <p class="title">
                                <em class="spanTitle" id="title2"><fmt:message key="performance.overview.szb"/>≥15</em>
                            </p>
                            <p class="sum"><fmt:message key="performance.overview.zsr"/>: <em id="count2-2"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wysr"/>：<em id="yoy2-2"></em></p>
                        </div>
                        <div class="chart fr chart-text">
                            <p class="sum"><fmt:message key="performance.overview.szb"/>：<em id="count2-1"></em></p>
                            <p class="sum"><fmt:message key="share.overview.kssl"/>：<em id="yoy2-1"></em> <fmt:message
                                    key="share.unit.ge"/></p>
                            <p class="line"></p>
                            <p class="sum"><fmt:message key="performance.overview.zzc"/>：<em id="count2-3"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wyzc"/>：<em id="count2-4"></em></p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                    <%-- 中维修 --%>
                <div class="frame" style="width:23%;">
                    <div class="border">
                        <div class="detail fl">
                            <p class="title"><em class="spanTitle" id="title3"><fmt:message
                                    key="performance.overview.szb"/>≥10</em></p>
                            <p class="sum"><fmt:message key="performance.overview.zsr"/>: <em id="count3-2"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wysr"/>：<em id="yoy3-2"></em></p>
                        </div>
                        <div class="chart fr chart-text">
                            <p class="sum"><fmt:message key="performance.overview.szb"/>：<em id="count3-1"></em></p>
                            <p class="sum"><fmt:message key="share.overview.kssl"/>：<em id="yoy3-1"></em> <fmt:message
                                    key="share.unit.ge"/></p>
                            <p class="line"></p>
                            <p class="sum"><fmt:message key="performance.overview.zzc"/>：<em id="count3-3"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wyzc"/>：<em id="count3-4"></em></p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>

                    <%-- 小维修 --%>
                <div class="frame" style="width:24%;">
                    <div class="border">
                        <div class="detail fl">
                            <p class="title"><em class="spanTitle" id="title4"><fmt:message
                                    key="performance.overview.szb"/><10</em></p>
                            <p class="sum"><fmt:message key="performance.overview.zsr"/>: <em id="count4-2"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wysr"/>：<em id="yoy4-2">&nbsp;</em>
                            </p>
                        </div>
                        <div class="chart fr chart-text">
                            <p class="sum"><fmt:message key="performance.overview.szb"/>：<em id="count4-1"></em></p>
                            <p class="sum"><fmt:message key="share.overview.kssl"/>：<em id="yoy4-1"></em> <fmt:message
                                    key="share.unit.ge"/></p>
                            <p class="line"></p>
                            <p class="sum"><fmt:message key="performance.overview.zzc"/>:<em id="count4-3"></em>
                                <fmt:message key="share.unit.wanyuan"/></p>
                            <p class="sum"><fmt:message key="performance.overview.wyzc"/>:<em id="count4-4"></em></p>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
            </div>

                <%--图表和排名--%>
            <div class="bottom_bar" style="flex:1;">
                    <%--左边部分--%>
                <div class="list_area fl">
                        <%--图表--%>
                    <div class="border chart-border">
                        <div class="area" style="position:relative;">
                            <p class="title">
                                <span class="fl"><span class="fb spanTitle" id="moredetail"><fmt:message
                                        key="charts.title.sbxhfb"/></span></span>
                                <span id="overyear" class="option_overyear"><fmt:message
                                        key="charts.button.yfxs"/></span>
                            </p>
                            <p class="fr title quadrantContainner">
                                <span class="quadrantName"><fmt:message key="charts.button.xx"/>：</span>
                                <span class="quadrant quadrant1">1</span>
                                <span class="quadrant quadrant2">2</span>
                                <span class="quadrant quadrant3">3</span>
                                <span class="quadrant quadrant4">4</span>
                            </p>
                            <div id="swiper">
                                <div class="swiper-container">
                                    <div class="slide home-device">
                                        <div class="chartArea" id="chart" style="height:100%;"></div>

                                        <input id="currentTag" style="display:none;" value="tendency"/>
                                        <div class="pagination pagination1"></div>
                                    </div>
                                </div>
                                    <%--<span class="btn btn-left">&lt;</span>
                                    <span class="btn btn-right">&gt;</span>--%>
                            </div>
                            <select id="tag" style="width:80px;">
                                <option value="1"><fmt:message key="performance.overview.sr"/></option>
                                <option value="2"><fmt:message key="performance.overview.zc"/></option>
                                <option value="0"><fmt:message key="performance.overview.szb"/></option>
                            </select>
                        </div>
                    </div>
                </div>
                    <%--左边结束--%>

                    <%--右侧排名--%>
                <div class="list_data fr">
                    <div class="border">
                        <div class="area">
                            <div class="data_detail">
                                <div id="top5_hospital" class="top5">
                                    <p class="title">
                                        <img src="<%=basePath%>/plugins/charts/images/yljg.png">
                                        <em id="morehospitals" class="spanTitle"><fmt:message
                                                key="share.table.head.yyks"/></em>
                                        <span>TOP5</span>
                                    </p>
                                    <p class="name"><span class="fl data_span_f"><fmt:message
                                            key="share.table.head.yyks"/></span><span
                                            class="fl listpercent data_span_s"><fmt:message
                                            key="performance.overview.szb"/></span><span
                                            class="fr listcontent"><fmt:message
                                            key="performance.table.sbje(wy)"/></span></p>
                                    <ul class="hospital" id="ul_hospital"></ul>
                                </div>
                                <div id="top5_type" class="top5">
                                    <p class="title">
                                        <img src="<%=basePath%>/plugins/charts/images/sblx.png">
                                        <em id="moretypes" class="spanTitle"><fmt:message
                                                key="share.table.head.sbxh"/></em>
                                        <span>TOP5</span></p>
                                    <p class="name">
                                        <span class="fl data_span_f"><fmt:message key="share.table.head.sbxh"/></span>
                                        <span class="fl listpercent data_span_s"><fmt:message
                                                key="performance.overview.szb"/></span>
                                        <span class="fr listcontent"><fmt:message
                                                key="performance.table.sbje(wy)"/></span>
                                    </p>
                                    <ul class="hospital" id="ul_type"></ul>
                                </div>
                                <div id="top5_brand" class="top5">
                                    <p class="title">
                                        <img src="<%=basePath%>/plugins/charts/images/sblx.png">
                                        <em id="morebrand" class="spanTitle"><fmt:message
                                                key="share.table.head.sbcj"/></em>
                                        <span>TOP5</span></p>
                                    <p class="name">
                                        <span class="fl data_span_f"><fmt:message key="share.table.head.sbcj"/></span>
                                        <span class="fl listpercent data_span_s"><fmt:message
                                                key="performance.overview.szb"/></span>
                                        <span class="fr listcontent"><fmt:message
                                                key="performance.table.sbje(wy)"/></span>
                                    </p>
                                    <ul class="hospital" id="ul_brand"></ul>
                                </div>

                                <div id="top5_year" class="top5" style="display:none;">
                                    <p class="title">
                                        <em id="moreyears" class="spanTitle" onclick="moreyear()"><fmt:message
                                                key="charts.button.yfxs"/></em>
                                    </p>
                                    <p class="name">
                                        <span class="fl data_span_f"><fmt:message key="share.table.head.yf"/></span>
                                        <span class="fl data_span_s"></span>
                                        <span class="fr listpercent"><fmt:message
                                                key="performance.overview.szb"/></span>
                                    </p>
                                    <ul class="hospital" id="ul_year"></ul>
                                </div>
                                <div id="top5_device" class="top5">
                                    <p class="title">
                                        <em id="moredevices" class="spanTitle"><fmt:message
                                                key="share.table.head.jtsb"/></em>
                                        <span>TOP5</span></p>
                                    <p class="name">
                                        <span class="fl data_span_f"><fmt:message key="share.table.head.sbmc"/></span>
                                        <span class="fl listpercent data_span_s"><fmt:message
                                                key="index.table.zb"/>(%)</span>
                                        <span class="fr listcontent"><fmt:message
                                                key="performance.table.sbje(wy)"/></span>
                                    </p>
                                    <ul class="hospital" id="ul_device"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                    <%--右侧结束--%>
            </div>
        </div>
        <div class="baseline"></div>
            <%--详情图表模态框--%>
        <div id="modal" style="display:none">
            <div class="row">
                <div class="col-md-12">
                    <div class="box-body no-padding">
                        <table id="tblSort" class="table table-bordered table-striped table-hover table-responsive">
                            <tbody id="table_data">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div id="typeModal" class="modal" style="display:none;padding-top: 58px;height: 100%;box-sizing: border-box;">
            <div class="row">
                <div class="col-md-12">
                    <div class="box-body no-padding">
                        <table id="typeTable" class="table table-bordered table-striped table-hover table-responsive">
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

        <%-- JS部分 --%>
    <script src="<%=basePath%>/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="<%=basePath%>/plugins/jQuery/jquery.cookie.js"></script>
    <script src="<%=basePath%>/plugins/fastclick/fastclick_1.0.6.min.js"></script>
    <script src="<%=basePath%>/plugins/flavr/flavr.min.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/echarts.min.js"></script>
    <!-- 引入 macarons 主题 -->
    <script src="<%=basePath%>/echarts/customed.js"></script>
    <script src="<%=basePath%>/plugins/select2/select2.full.min.js"></script>
    <script src="<%=basePath%>/plugins/select2/i18n/zh-CN.js"></script>
    <script src="<%=basePath%>/plugins/iziModal/js/iziModal.min.js"></script>
    <script src="<%=basePath%>/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/plugins.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/tableHeadFixer.js"></script>
    <script>
        /*--------- 全局变量 ---------*/
        var CONST = 1000000,
            modelName = '',
            basePath = '<%=basePath%>',
            queryMaxValue = '',
            queryMinValue = '';
        /*--------- 全局变量 ---------*/

        /* 页面初始化 */
        $(function () {
            loading(function () {
                addChooseRadioEvent('hospital');
                resizeWindow();
                initChart();  // 初始化图表
                ChooseBox.siblingsClick();
                querySearch("hospital", '');
                querySearch("risk", '');
                querySearch("type", '');
                querySearch("brand", '');
                querySearch("year", '');
                getParams();
                appendTime();
                clickToggle($('.quadrant'));
                clickChange($('.detail .title em'));
                $("#btn5").click(function () {
                    ChooseBox.toggle();
                });

                $('#tag').select2();
                $('#tag').on('change', function (e) {
                    setChatsData($(this).val());
                    setUlHospital('desc', 0);
                    setUlType('desc', 0);
                    setUlBrand('desc', 0);
                    setUlDevice('desc', 0);
                });
            });
        });

        $('#title1').click(function () {
            loading(function () {
                queryMaxValue = '';
                queryMinValue = '';
                queryChartsData();
                queryTypeTop5Data();
                queryBrandTop5Data();
                queryDeviceTop5Data();
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
                $('.option_overyear').html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);
            });
        });
        $('#title2').click(function () {
            loading(function () {
                queryMaxValue = '';
                queryMinValue = queryMax;
                queryChartsData();
                queryTypeTop5Data();
                queryBrandTop5Data();
                queryDeviceTop5Data();
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
                $('.option_overyear').html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);
            });
        });
        $('#title3').click(function () {
            loading(function () {
                queryMaxValue = queryMax;
                queryMinValue = queryMin;
                queryChartsData();
                queryTypeTop5Data();
                queryBrandTop5Data();
                queryDeviceTop5Data();
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
                $('.option_overyear').html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);
            });
        });
        $('#title4').click(function () {
            loading(function () {
                queryMaxValue = queryMin;
                queryMinValue = '';
                queryChartsData();
                queryTypeTop5Data();
                queryBrandTop5Data();
                queryDeviceTop5Data();
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
                $('.option_overyear').html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);
            });
        });

        // 初始化图表并添加图表点击事件
        function initChart() {
            chart = echarts.init(document.getElementById('chart'), 'customed');  // 初始化echarts实例
            chart.on("click", click);
        }

        var queryStatus = {
            arr: ['hospital', 'model', 'brand', 'assets'],
            getStatus: function () {
                for (var i = 0; i < this.arr.length; i++) {
                    if (!this[this.arr[i]]) return false;
                }
                return true;
            },
            resetStatus: function () {
                for (var i = 0; i < this.arr.length; i++) {
                    this[this.arr[i]] = false;
                }
            }
        };
        function click(param) {
            if (typeof param.seriesIndex === 'undefined') {
                return;
            }
            if (param.componentType === 'markLine') {
                return;
            }
            loading();
            if (param.type === 'click') {
                var index = param.dataIndex;
                if ($('#overyear').hasClass('active')) {
                    loading(true);
                    return;
                    $('#overyear').removeClass('active');
                    getParams();
                } else {
                    var tab;
                    if (modelName == idsType[index]) {
                        modelName = '';
                        tab = false;
                        index = 0;
                    } else {
                        modelName = idsType[index];
                        tab = true;
                    }
                    setUlType('desc', index, tab);
                    queryStatus.model = true;
                    queryChartsData();
                    queryBrandTop5Data();
                    queryDeviceTop5Data();
                }
            }
        }


        //查询筛选条件
        var typeIdArr;

        function querySearch(tag, tagId) {
            var url = "<%=basePath%>/hospital/search/" + (tag == 'hospital' ? 'department' : tag);
            $.ajax({
                type: "POST",
                data: {
                  hospitalId: hspId},
                url: url,
                async: false,
                dataType: "json",
                success: function (data) {
                    if (data.ret == 1) {
                        data.data = data.data || {list: []};
                        var searchData = data.data;
                        setSearch(tag, searchData);
                        $('.select_' + tag).select2({
                            placeholder: '<fmt:message key="share.sift.qxz"/>',
                            allowClear: true
                        });
                        ChooseBox.setSearchFromCookie(tag);
                        if (tag == 'type') {
                            searchDataGlobal = searchData;
                            $('.select_type').on('select2:select', function (param) {
                                typeIdArr = $('.select_type').val();
                                var id = param.params.data.id;
                                if (id < 2016102346) {
                                    for (var i = 0; i < searchDataGlobal[id].length; i++) {
                                        typeIdArr.push(searchDataGlobal[id][i].id)
                                    }
                                }
                                $('.select_type').val(typeIdArr).trigger('change');
                            });
                            $('.select_type').on('select2:unselect', function (param) {
                                typeIdArr = $('.select_type').val();
                                var id = param.params.data.id;
                                typeIdArr.removeByValue(id);
                                if (id < 2016102346) {
                                    for (var i = 0; i < searchDataGlobal[id].length; i++) {
                                        typeIdArr.removeByValue(searchDataGlobal[id][i].id)
                                    }
                                }
                                $('.select_type').val(typeIdArr).trigger('change');
                            });
                        }
                        if (tag == 'type' && window.location.search.split('=')[1]) {
                            typeId = GetQueryString('typeId') ? [GetQueryString('typeId')] : '';
                            $('.select_type').val(typeId).trigger('change');
                        }
                    } else {
                        if (data.msg == '该用户不存在') {
                            location.href = '<%=basePath%>';
                        } else {
                            flavrShowByTime(data.msg, null, "danger", false);
                        }
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }

        /* 设置搜索框搜索条件 */
        function setSearch(tag, data) {
            var first, second, id, str, str1;
            if (tag === "type") {
                str = '';
                first = data.first;
                for (var i = 0; i < first.length; i++) {
                    //一级设备
                    if ('${sessionScope.locale}'.indexOf('en') != -1) {
                        str += '<optgroup label="' + (first[i].enName || "") + '">' +
                            (function () {
                                str1 = '';
                                id = first[i].id;
                                if (data[id]) {
                                    //一级设备
                                    str1 = '<option value="' + first[i].id + '">' + (first[i].enName || "") + '</option>';
                                    second = data[id];
                                    for (var j = 0; j < second.length; j++) {
                                        //二级设备
                                        str1 += '<option value="' + second[j].id + '">' + (second[j].enName || "") + '</option>';
                                    }
                                } else {
                                    str1 = '<option value="' + first[i].id + '">' + (first[i].enName || "") + '</option>';
                                }
                                return str1;
                            })() +
                            '</optgroup>';
                    } else {
                        str += '<optgroup label="' + (first[i].name || "") + '">' +
                            (function () {
                                str1 = '';
                                id = first[i].id;
                                if (data[id]) {
                                    //一级设备
                                    str1 = '<option value="' + first[i].id + '">' + (first[i].name || "") + '</option>';
                                    second = data[id];
                                    for (var j = 0; j < second.length; j++) {
                                        //二级设备
                                        str1 += '<option value="' + second[j].id + '">' + (second[j].name || "") + '</option>';
                                    }
                                } else {
                                    str1 = '<option value="' + first[i].id + '">' + (first[i].name || "") + '</option>';
                                }
                                return str1;
                            })() +
                            '</optgroup>';
                    }
                }
                $(".select_type").append(str);
            } else {
                data = data.list;
                if (tag == 'department') {
                    if ('${sessionScope.locale}'.indexOf('en') != -1) {
                        for (var i = 0; i < data.length; i++) {
                            $(".select_" + 'hospital').append('<option value="' + data[i].id + '">' + (data[i].enName || "") + '</option>');
                        }
                    } else {
                        for (var i = 0; i < data.length; i++) {
                            $(".select_" + 'hospital').append('<option value="' + data[i].id + '">' + (data[i].name || "") + '</option>');
                        }
                    }
                } else {
                    if ('${sessionScope.locale}'.indexOf('en') != -1) {
                        for (var i = 0; i < data.length; i++) {
                            $(".select_" + tag).append('<option value="' + data[i].id + '">' + (data[i].enName || "") + '</option>');
                        }
                    } else {
                        for (var i = 0; i < data.length; i++) {
                            $(".select_" + tag).append('<option value="' + data[i].id + '">' + (data[i].name || "") + '</option>');
                        }
                    }
                }
            }

        }

        //全市详情
        function queryAllAssets() {
            $.ajax({
                type: "POST",
                url: "<%=basePath%>/charts/hospital/hospital-cost/overview",
                async: true,
                data: {
                  hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd
                },
                dataType: "json",
                success: function (data) {
                    if (data.ret == 1) {
                        data.data = data.data || {list: []};
                        data = data.data.list;
                        assets = data;
                        // 收支比 及 医院数量
                        $('#count1-1').html(parseFloat(data.overview_1.jnszPercentage || 0).toFixed(2));
                        $('#yoy1-1').html(data.overview_1.departmentNum || 0);
                        // 总收入 及 万元收入
                        $('#count1-2').html(parseFloat((data.overview_1.jnTotalIncome / CONST) || 0).toFixed(2));
                        $('#yoy1-2').html(parseFloat(data.overview_1.jnwyIncomePercentage || 0).toFixed(2));
                        // 总支出 及 万元支出
                        $('#count1-3').html(parseFloat((data.overview_1.jnTotalExpenditure / CONST) || 0).toFixed(2));
                        $('#count1-4').html(parseFloat(data.overview_1.jnwyExpenditurePercentage || 0).toFixed(2));

                        // 收支比 及 医院数量
                        $('#count2-1').html(parseFloat(data.overview_2.jnszPercentage || 0).toFixed(2));
                        $('#yoy2-1').html(data.overview_2.departmentNum || 0);
                        // 总收入 及 万元收入
                        $('#count2-2').html(parseFloat((data.overview_2.jnTotalIncome / CONST) || 0).toFixed(2));
                        $('#yoy2-2').html(parseFloat(data.overview_2.jnwyIncomePercentage || 0).toFixed(2));
                        // 总支出 及 万元支出
                        $('#count2-3').html(parseFloat((data.overview_2.jnTotalExpenditure / CONST) || 0).toFixed(2));
                        $('#count2-4').html(parseFloat(data.overview_2.jnwyExpenditurePercentage || 0).toFixed(2));

                        // 收支比 及 医院数量
                        $('#count3-1').html(parseFloat(data.overview_3.jnszPercentage || 0).toFixed(2));
                        $('#yoy3-1').html(data.overview_3.departmentNum || 0);
                        // 总收入 及 万元收入
                        $('#count3-2').html(parseFloat((data.overview_3.jnTotalIncome / CONST) || 0).toFixed(2));
                        $('#yoy3-2').html(parseFloat(data.overview_3.jnwyIncomePercentage || 0).toFixed(2));
                        // 总支出 及 万元支出
                        $('#count3-3').html(parseFloat((data.overview_3.jnTotalExpenditure / CONST) || 0).toFixed(2));
                        $('#count3-4').html(parseFloat(data.overview_3.jnwyExpenditurePercentage || 0).toFixed(2));

                        // 收支比 及 医院数量
                        $('#count4-1').html(parseFloat(data.overview_4.jnszPercentage || 0).toFixed(2));
                        $('#yoy4-1').html(data.overview_4.departmentNum || 0);
                        // 总收入 及 万元收入
                        $('#count4-2').html(parseFloat((data.overview_4.jnTotalIncome / CONST) || 0).toFixed(2));
                        $('#yoy4-2').html(parseFloat(data.overview_4.jnwyIncomePercentage || 0).toFixed(2));
                        // 总支出 及 万元支出
                        $('#count4-3').html(parseFloat((data.overview_4.jnTotalExpenditure / CONST) || 0).toFixed(2));
                        $('#count4-4').html(parseFloat(data.overview_4.jnwyExpenditurePercentage || 0).toFixed(2));
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            });
        }


        //医院top5
        function setUlHospital(sortord, index, tab) {
            index = index ? index : 0;
            var sel = $('#tag').val();
            var len = xAxis.length;
            var x = 0,
                y = 0;
            if (index < 3) {
                x = 0;
            } else if (len - index < 3) {
                x = (len - 5) > 0 ? (len - 5) : 0;
            } else {
                x = index - 2;
            }
            y = len > 5 ? x + 5 : len;
            var percent, count;
            $("#ul_hospital").html('');
            for (var i = x; i < y; i++) {
                if (sel == 0) {
                    percent = parseFloat(jnszPercentage[i] || 0).toFixed(2);
                } else if (sel == 1) {
                    percent = parseFloat(jnIncome[i] || 0).toFixed(2);
                } else if (sel == 2) {
                    percent = parseFloat(jnExpenditure[i] || 0).toFixed(2);
                }
                count = parseFloat(jnAssetsAmount[i]).toFixed(2);
                $("#ul_hospital").append(
                    '<li><a title="' + (i + 1) + ' ' + fullName[i] + '"' + ((tab && i == index) ? 'class="active"' : '') + ' onclick="query(\'hospital\',\''+ids[i]+'\')"><span class="fl data_span_f spanTitle">' + xAxis[i] + '</span><em class="fl data_span_s">'
                    + percent + '</em><em class="fr">'
                    + count + '</em></a></li>');
            }
        }

        //设置与图表对应的表的内容
        function setUlType(sortord, index, tab) {
            index = index ? index : 0;
            var sel = $('#tag').val();
            var len = xAxisType.length;
            var x = 0,
                y = 0;
            if (index < 3) {
                x = 0;
            } else if (len - index < 3) {
                x = (len - 5) > 0 ? (len - 5) : 0;
            } else {
                x = index - 2;
            }
            y = len > 5 ? x + 5 : len;
            var percent, count;
            $("#ul_type").html('');
            for (var i = x; i < y; i++) {
                if (sel == 0) {
                    percent = parseFloat(jnszPercentageType[i] || 0).toFixed(2);
                } else if (sel == 1) {
                    percent = parseFloat(jnIncomeType[i] || 0).toFixed(2);
                } else if (sel == 2) {
                    percent = parseFloat(jnExpenditureType[i] || 0).toFixed(2);
                }
                count = parseFloat(jnAssetsAmountType[i]).toFixed(2);
                $("#ul_type").append(
                    '<li><a title="' + (i + 1) + ' ' + fullNameType[i] + '"' + ((tab && i == index) ? 'class="active"' : '') + ' onclick="query(\'type\',\''+idsType[i]+'\')"><span class="fl data_span_f spanTitle">' + xAxisType[i] + '</span><em class="fl data_span_s">'
                    + percent + '</em><em class="fr">'
                    + count + '</em></a></li>'
                );
            }
        }

        //设置与图表对应的表的内容
        function setUlBrand(sortord, index, tab) {
            index = index ? index : 0;
            var sel = $('#tag').val();
            var len = xAxisBrand.length;
            var x = 0,
                y = 0;
            if (index < 3) {
                x = 0;
            } else if (len - index < 3) {
                x = (len - 5) > 0 ? (len - 5) : 0;
            } else {
                x = index - 2;
            }
            y = len > 5 ? x + 5 : len;
            var percent, count;
            $("#ul_brand").html('');
            for (var i = x; i < y; i++) {
                if (sel == 0) {
                    percent = parseFloat(jnszPercentageBrand[i] || 0).toFixed(2);
                } else if (sel == 1) {
                    percent = parseFloat(jnIncomeBrand[i] || 0).toFixed(2);
                } else if (sel == 2) {
                    percent = parseFloat(jnExpenditureBrand[i] || 0).toFixed(2);
                }
                count = parseFloat(jnAssetsAmountBrand[i]).toFixed(2);
                $("#ul_brand").append(
                    '<li><a title="' + (i + 1) + ' ' + fullNameBrand[i] + '"' + ((tab && i == index) ? 'class="active"' : '') + ' onclick="query(\'brand\',\''+idsBrand[i]+'\')"><span class="fl data_span_f spanTitle">' + xAxisBrand[i] + '</span><em class="fl data_span_s">'
                    + percent + '</em><em class="fr">'
                    + count + '</em></a></li>'
                );
            }
        }

        function setUlDevice(sortord, index, tab) {
            index = index ? index : 0;
            var sel = $('#tag').val();
            var len = xAxisDevice.length;
            var x = 0,
                y = 0;
            if (index < 3) {
                x = 0;
            } else if (len - index < 3) {
                x = (len - 5) > 0 ? (len - 5) : 0;
            } else {
                x = index - 2;
            }
            y = len > 5 ? x + 5 : len;
            var percent, count;
            $("#ul_device").html('');
            for (var i = x; i < y; i++) {
                if (sel == 0) {
                    percent = parseFloat(jnszPercentageDevice[i] || 0).toFixed(2);
                } else if (sel == 1) {
                    percent = parseFloat(jnIncomeDevice[i] || 0).toFixed(2);
                } else if (sel == 2) {
                    percent = parseFloat(jnExpenditureDevice[i] || 0).toFixed(2);
                }
                count = parseFloat(jnAssetsAmountDevice[i]).toFixed(2);
                $("#ul_device").append(
                    '<li><a title="'+ (i + 1) + ' ' + fullNameDevice[i] + '" onclick="query(\'device\',\''+idsDevice[i]+'\')"><span class="fl data_span_f spanTitle">' + xAxisDevice[i] + '</span><em class="fl data_span_s">'
                    + percent + '</em><em class="fr">'
                    + count + '</em></a></li>'
                );
            }
        }

        //获取筛选条件参数
        function getParams() {
            loading(function () {
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
                $('.option_overyear').html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);

                hospitalId = $('.select_hospital').val() ? $('.select_hospital').val() : '';
                riskId = $('.select_risk').val() ? $('.select_risk').val() : '';
                typeId = $('.select_type').val() ? $('.select_type').val() : '';
                brandId = $('.select_brand').val() ? $('.select_brand').val() : '';
                year = $('.select_year').val() ? $('.select_year').val() : '';
                monthId = $('.select_month').val() ? $('.select_month').val() : '';
                enableYearStart = $('#enableYearStart').val() ? $('#enableYearStart').val() : '';
                enableYearEnd = $('#enableYearEnd').val() ? $('#enableYearEnd').val() : '';
                priceStart = $('#priceStart').val() ? $('#priceStart').val() * CONST : '';
                priceEnd = $('#priceEnd').val() ? $('#priceEnd').val() * CONST : '';
                ageLimitStart = $('#ageLimitStart').val() ? $('#ageLimitStart').val() : '';
                ageLimitEnd = $('#ageLimitEnd').val() ? $('#ageLimitEnd').val() : '';

                $.cookie('chooseValue', JSON.stringify({
                    hospitalId: hospitalId,
                    riskId: riskId,
                    typeId: typeId,
                    brandId: brandId,
                    year: year,
                    monthId: monthId,
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd
                }), {path: '/'});

                $.ajax({
                    type: "POST",
                    data: {
                        hospitalId: hspId,
                        departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                        riskId: riskId ? JSON.stringify(riskId) : '',
                        typeId: typeId ? JSON.stringify(typeId) : '',
                        brandId: brandId ? JSON.stringify(brandId) : '',
                        year: year ? JSON.stringify(year) : '',
                        monthId: monthId ? JSON.stringify(monthId) : '',
                        enableYearStart: enableYearStart,
                        enableYearEnd: enableYearEnd,
                        priceStart: priceStart,
                        priceEnd: priceEnd,
                        ageLimitStart: ageLimitStart,
                        ageLimitEnd: ageLimitEnd
                    },
                    url: '<%=basePath%>/charts/hospital/hospital-cost/queryInterval',
                    async: false,
                    dataType: "json",
                    success: function (data) {
                        if (data.ret == 1) {
                            data.data = data.data || {list: []};
                            type = data.data.type - 2;
                            queryMax = data.data.queryMax;
                            queryMin = data.data.queryMin;
                            var $type_choose = $('#tag').find('option').removeAttr('selected').removeAttr('disabled');

                            if (type == 0) {
                                $type_choose.eq(2).attr('selected', 'selected');    // 收支比默认选中

                                $('#title2').html('<fmt:message key="performance.overview.szb"/>≥' + queryMax);
                                $('#title3').html('<fmt:message key="performance.overview.szb"/>≥' + queryMin);
                                $('#title4').html('<fmt:message key="performance.overview.szb"/><' + queryMin);
                            } else if (type == 1) {
                                $type_choose.eq(0).attr('selected', 'selected');    // 收入默认选中
                                $type_choose.eq(2).attr('disabled', 'disabled');    // 收支比不能被选中
                                $type_choose.eq(1).attr('disabled', 'disabled');    // 支出不能被选中

                                $('#title2').html('<fmt:message key="performance.overview.sr"/>≥' + parseInt(queryMax / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                                $('#title3').html('<fmt:message key="performance.overview.sr"/>≥' + parseInt(queryMin / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                                $('#title4').html('<fmt:message key="performance.overview.sr"/><' + parseInt(queryMin / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                            } else if (type == 2) {
                                $type_choose.eq(1).attr('selected', 'selected');    // 支出默认选中
                                $type_choose.eq(2).attr('disabled', 'disabled');    // 收支比不能被选中
                                $type_choose.eq(0).attr('disabled', 'disabled');    // 收入不能被选中

                                $('#title2').html('<fmt:message key="performance.overview.zc"/>≥' + parseInt(queryMax / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                                $('#title3').html('<fmt:message key="performance.overview.zc"/>≥' + parseInt(queryMin / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                                $('#title4').html('<fmt:message key="performance.overview.zc"/><' + parseInt(queryMin / CONST) + '<fmt:message key="share.unit.wanyuan"/>');
                            }
                            $('#tag').select2();
                            $('#tag').val(type).trigger('change');
                        } else {
                            flavrShowByTime(data.msg, null, "danger", false);
                        }
                    },
                    failure: function () {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                });
                queryAllAssets();
                queryChartsData();
                queryTypeTop5Data();
                queryBrandTop5Data();
                queryDeviceTop5Data();
            });
        }


        // 获取图表数据(医院)
        function queryChartsData(tableId) {
            ids = [];
            xAxis = [];
            jnIncome = [];                  // 今年收入
            jnIncomeAssetsNum = [];         // 今年收入设备数量
            jnExpenditure = [];             // 今年支出
            jnExpenditureAssetsNum = [];    // 今年支出设备数量
            jnszPercentage = [];            // 今年收支比
            qnIncome = [];                  // 去年
            qnIncomeAssetsNum = [];         // 去年
            qnExpenditure = [];             // 去年
            qnExpenditureAssetsNum = [];    // 去年
            qnszPercentage = [];            // 去年
            tbszPercentage = [];            // 收支比同比
            jnAssetsAmount = [];            // 今年设备总额
            jnwyPercentage = [];            // 今年万元收支比
            qnAssetsAmount = [];            // 去年
            qnwyPercentage = [];            // 去年
            tbwyPercentage = [];            // 万元收支比同比
            deviceTypeSubNum = [];          // 设备类型数量
            manufacturerNum = [];           // 厂商数量
            hospitalNum = [];               // 医院数量
            series = [];                    // 气泡图数据
            fullName = [];

            hospitalJson = [];
            $.ajax({
                type: "POST",
                url: '<%=basePath%>/charts/hospital/hospital-cost/department',
                data: {
                  hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    modelName: modelName,
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd,
                    queryType: type + 2,
                    queryMax: queryMaxValue,
                    queryMin: queryMinValue
                },
                dataType: "json",
                success: function (data) {
                    if (data.ret) {
                        data.data = data.data || {list: []};
                        hospitalJson = (data.data.list || []).sortByKey('jnAssetsAmount').calTotal();
                        if (data.data.list) {
                            for (var i = 0; i < data.data.list.length; i++) {
                                if ('${sessionScope.locale}'.indexOf('en') != -1) {
                                    xAxis.push(data.data.list[i].enName || '');
                                    fullName.push(data.data.list[i].fullEnName || '');
                                } else {
                                    xAxis.push(data.data.list[i].name || '');
                                    fullName.push(data.data.list[i].fullName || '');
                                }
                                ids.push(data.data.list[i].id || '');
                                jnIncome.push(parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2));
                                jnIncomeAssetsNum.push(data.data.list[i].jnIncomeAssetsNum || 0);
                                jnExpenditure.push(parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2));
                                jnExpenditureAssetsNum.push(data.data.list[i].jnExpenditureAssetsNum || 0);
                                jnszPercentage.push(parseFloat((data.data.list[i].jnszPercentage) || 0).toFixed(2));
                                qnIncome.push(parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2));
                                qnIncomeAssetsNum.push(data.data.list[i].qnIncomeAssetsNum || 0);
                                qnExpenditure.push(parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2));
                                qnExpenditureAssetsNum.push(data.data.list[i].qnExpenditureAssetsNum || 0);
                                qnszPercentage.push(parseFloat((data.data.list[i].qnszPercentage) || 0).toFixed(2));
                                tbszPercentage.push(parseFloat((data.data.list[i].tbszPercentage) || 0).toFixed(2));
                                jnAssetsAmount.push(parseFloat((data.data.list[i].jnAssetsAmount / CONST) || 0).toFixed(2));
                                jnwyPercentage.push(parseFloat((data.data.list[i].jnwyPercentage) || 0).toFixed(2));
                                qnAssetsAmount.push(parseFloat((data.data.list[i].qnAssetsAmount / CONST) || 0).toFixed(2));
                                qnwyPercentage.push(parseFloat((data.data.list[i].qnwyPercentage) || 0).toFixed(2));
                                tbwyPercentage.push(parseFloat((data.data.list[i].jnwyExpenditurePercentage) || 0).toFixed(2));
                                deviceTypeSubNum.push(data.data.list[i].deviceTypeSubNum || 0);
                                manufacturerNum.push(data.data.list[i].manufacturerNum || 0);
                                hospitalNum.push(data.data.list[i].hospitalNum || 0);
                            }
                            sort('desc', jnAssetsAmount, ids, xAxis, jnIncome, jnIncomeAssetsNum, jnExpenditure, jnExpenditureAssetsNum, jnszPercentage, qnIncome, qnIncomeAssetsNum, qnExpenditure, qnExpenditureAssetsNum, qnszPercentage, tbszPercentage, jnwyPercentage, qnAssetsAmount, qnwyPercentage, tbwyPercentage, deviceTypeSubNum, manufacturerNum, hospitalNum, fullName);
                        }
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                    setUlHospital('desc', 0);
                    if ((!$('#modal').is(':hidden')) && ($('#modal').attr('modal') == 'hospital')) morehospitals();

                    queryStatus.hospital = true;
                    if (queryStatus.getStatus()) {
                        loading(true);
                        queryStatus.resetStatus();
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }

        // 获取图表数据(设备类型)
        function queryTypeTop5Data(tableId) {
            idsType = [];
            xAxisType = [];
            jnIncomeType = [];                  // 今年收入
            jnIncomeAssetsNumType = [];         // 今年收入设备数量
            jnExpenditureType = [];             // 今年支出
            jnExpenditureAssetsNumType = [];    // 今年支出设备数量
            jnszPercentageType = [];            // 今年收支比
            qnIncomeType = [];                  // 去年
            qnIncomeAssetsNumType = [];         // 去年
            qnExpenditureType = [];             // 去年
            qnExpenditureAssetsNumType = [];    // 去年
            qnszPercentageType = [];            // 去年
            tbszPercentageType = [];            // 收支比同比
            jnAssetsAmountType = [];            // 今年设备总额
            jnwyPercentageType = [];            // 今年万元收支比
            qnAssetsAmountType = [];            // 去年
            qnwyPercentageType = [];            // 去年
            tbwyPercentageType = [];            // 万元收支比同比
            deviceTypeSubNumType = [];          // 设备类型数量
            manufacturerNumType = [];           // 厂商数量
            hospitalNumType = [];               // 医院数量
            fullNameType = [];

            typeJson = [];
            $.ajax({
                type: "POST",
                url: '<%=basePath%>/charts/hospital/hospital-cost/model',
                data: {
                  hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd,
                    queryType: type + 2,
                    queryMax: queryMaxValue,
                    queryMin: queryMinValue
                },
                dataType: "json",
                success: function (data) {
                    if (data.ret) {
                        data.data = data.data || {list: []};
                        typeJson = (data.data.list || []).sortByKey('jnAssetsAmount').calTotal();
                        if (data.data.list) {
                            for (var i = 0; i < data.data.list.length; i++) {
                                idsType.push(data.data.list[i].id || '');
                                xAxisType.push(data.data.list[i].name || '');
                                jnIncomeType.push(parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2));
                                jnIncomeAssetsNumType.push(data.data.list[i].jnIncomeAssetsNum || 0);
                                jnExpenditureType.push(parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2));
                                jnExpenditureAssetsNumType.push(data.data.list[i].jnExpenditureAssetsNum || 0);
                                jnszPercentageType.push(parseFloat((data.data.list[i].jnszPercentage) || 0).toFixed(2));
                                qnIncomeType.push(parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2));
                                qnIncomeAssetsNumType.push(data.data.list[i].qnIncomeAssetsNum || 0);
                                qnExpenditureType.push(parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2));
                                qnExpenditureAssetsNumType.push(data.data.list[i].qnExpenditureAssetsNum || 0);
                                qnszPercentageType.push(parseFloat((data.data.list[i].qnszPercentage) || 0).toFixed(2));
                                tbszPercentageType.push(parseFloat((data.data.list[i].tbszPercentage) || 0).toFixed(2));
                                jnAssetsAmountType.push(parseFloat((data.data.list[i].jnAssetsAmount / CONST) || 0).toFixed(2));
                                jnwyPercentageType.push(parseFloat((data.data.list[i].jnwyPercentage) || 0).toFixed(2));
                                qnAssetsAmountType.push(parseFloat((data.data.list[i].qnAssetsAmount / CONST) || 0).toFixed(2));
                                qnwyPercentageType.push(parseFloat((data.data.list[i].qnwyPercentage) || 0).toFixed(2));
                                tbwyPercentageType.push(parseFloat((data.data.list[i].jnwyExpenditurePercentage) || 0).toFixed(2));
                                deviceTypeSubNumType.push(data.data.list[i].deviceTypeSubNum || 0);
                                manufacturerNumType.push(data.data.list[i].manufacturerNum || 0);
                                hospitalNumType.push(data.data.list[i].hospitalNum || 0);
                                fullNameType.push(data.data.list[i].fullName || '');
                            }
                            sort('desc', jnAssetsAmountType, idsType, xAxisType, jnIncomeType, jnIncomeAssetsNumType, jnExpenditureType, jnExpenditureAssetsNumType, jnszPercentageType, qnIncomeType, qnIncomeAssetsNumType, qnExpenditureType, qnExpenditureAssetsNumType, qnszPercentageType, tbszPercentageType, jnwyPercentageType, qnAssetsAmountType, qnwyPercentageType, tbwyPercentageType, deviceTypeSubNumType, manufacturerNumType, hospitalNumType, fullNameType);
                            avgAssetsAmount = parseFloat((data.data.avgAssetsAmount / CONST) || 0).toFixed(2);  // 设备金额平均数
                            avgIncome = parseFloat((data.data.avgIncome / CONST) || 0).toFixed(2);  // 收入平均数
                            avgExpenditure = parseFloat((data.data.avgExpenditure / CONST) || 0).toFixed(2);  // 支出平均数
                            avgSzPercentage = parseFloat(data.data.avgSzPercentage || 0).toFixed(2);  // 收支比平均数
                        }
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                    optionAgelimit.series[0].markLine.data[0].xAxis = avgAssetsAmount;
                    setChatsData(type);
                    setUlType('desc', 0);
                    if ((!$('#modal').is(':hidden')) && ($('#modal').attr('modal') == 'type')) moretypes();

                    queryStatus.model = true;
                    if (queryStatus.getStatus()) {
                        loading(true);
                        queryStatus.resetStatus();
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }

        /*
        * tag   select的值　0-收支比  1-收入  2-支出
        * 设置图表数据
        * */
        function setChatsData(tag) {
            type = tag;
            series = [];
            if (tag == 0) {
                $('.listpercent').html('<fmt:message key="performance.overview.szb"/>');
                optionAgelimit.yAxis[0].name = '<fmt:message key="performance.overview.szb"/>';
                optionAgelimit.series[0].markLine.data[1].name = '<fmt:message key="charts.axis.szbpjz(%)"/>';
                optionAgelimit.series[0].markLine.data[1].yAxis = avgSzPercentage;
                for (var i = 0; i < xAxisType.length; i++) {
                    series.push([jnAssetsAmountType[i], jnszPercentageType[i], 50, xAxisType[i]]);
                }
            } else if (tag == 1) {
                $('.listpercent').html('<fmt:message key="performance.table.sr(wy)"/>');
                optionAgelimit.yAxis[0].name = '<fmt:message key="charts.axis.sr-wy"/>';
                optionAgelimit.series[0].markLine.data[1].name = '<fmt:message key="charts.axis.srpjz(wy)"/>';
                optionAgelimit.series[0].markLine.data[1].yAxis = avgIncome;
                for (var i = 0; i < xAxisType.length; i++) {
                    series.push([jnAssetsAmountType[i], jnIncomeType[i], 50, xAxisType[i]]);
                }
            } else if (tag == 2) {
                $('.listpercent').html('<fmt:message key="performance.table.zc(wy)"/>');
                optionAgelimit.yAxis[0].name = '<fmt:message key="charts.axis.zc-wy"/>';
                optionAgelimit.series[0].markLine.data[1].name = '<fmt:message key="charts.axis.zcpjz(wy)"/>';
                optionAgelimit.series[0].markLine.data[1].yAxis = avgExpenditure;
                for (var i = 0; i < xAxisType.length; i++) {
                    series.push([jnAssetsAmountType[i], jnExpenditureType[i], 50, xAxisType[i]]);
                }
            }
            optionAgelimit.series[0].data = series;
            chart.clear();
            chart.setOption(optionAgelimit);
        }

        // 获取图表数据(设备类型)
        function queryBrandTop5Data(tableId) {
            idsBrand = [];
            xAxisBrand = [];
            jnIncomeBrand = [];                  // 今年收入
            jnIncomeAssetsNumBrand = [];         // 今年收入设备数量
            jnExpenditureBrand = [];             // 今年支出
            jnExpenditureAssetsNumBrand = [];    // 今年支出设备数量
            jnszPercentageBrand = [];            // 今年收支比
            qnIncomeBrand = [];                  // 去年
            qnIncomeAssetsNumBrand = [];         // 去年
            qnExpenditureBrand = [];             // 去年
            qnExpenditureAssetsNumBrand = [];    // 去年
            qnszPercentageBrand = [];            // 去年
            tbszPercentageBrand = [];            // 收支比同比
            jnAssetsAmountBrand = [];            // 今年设备总额
            jnwyPercentageBrand = [];            // 今年万元收支比
            qnAssetsAmountBrand = [];            // 去年
            qnwyPercentageBrand = [];            // 去年
            tbwyPercentageBrand = [];            // 万元收支比同比
            deviceTypeSubNumBrand = [];          // 设备类型数量
            manufacturerNumBrand = [];           // 厂商数量
            hospitalNumBrand = [];               // 医院数量
            fullNameBrand = [];

            brandJson = [];
            $.ajax({
                type: "POST",
                url: '<%=basePath%>/charts/hospital/hospital-cost/brand',
                data: {
                  hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd,
                    queryType: type + 2,
                    queryMax: queryMaxValue,
                    queryMin: queryMinValue
                },
                dataType: "json",
                success: function (data) {
                    if (data.ret) {
                        data.data = data.data || {list: []};
                        brandJson = (data.data.list || []).sortByKey('jnAssetsAmount').calTotal();
                        if (data.data.list) {
                            for (var i = 0; i < data.data.list.length; i++) {
                                idsBrand.push(data.data.list[i].id || '');
                                xAxisBrand.push(data.data.list[i].name || '');
                                jnIncomeBrand.push(parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2));
                                jnIncomeAssetsNumBrand.push(data.data.list[i].jnIncomeAssetsNum || 0);
                                jnExpenditureBrand.push(parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2));
                                jnExpenditureAssetsNumBrand.push(data.data.list[i].jnExpenditureAssetsNum || 0);
                                jnszPercentageBrand.push(parseFloat((data.data.list[i].jnszPercentage) || 0).toFixed(2));
                                qnIncomeBrand.push(parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2));
                                qnIncomeAssetsNumBrand.push(data.data.list[i].qnIncomeAssetsNum || 0);
                                qnExpenditureBrand.push(parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2));
                                qnExpenditureAssetsNumBrand.push(data.data.list[i].qnExpenditureAssetsNum || 0);
                                qnszPercentageBrand.push(parseFloat((data.data.list[i].qnszPercentage) || 0).toFixed(2));
                                tbszPercentageBrand.push(parseFloat((data.data.list[i].tbszPercentage) || 0).toFixed(2));
                                jnAssetsAmountBrand.push(parseFloat((data.data.list[i].jnAssetsAmount / CONST) || 0).toFixed(2));
                                jnwyPercentageBrand.push(parseFloat((data.data.list[i].jnwyPercentage) || 0).toFixed(2));
                                qnAssetsAmountBrand.push(parseFloat((data.data.list[i].qnAssetsAmount / CONST) || 0).toFixed(2));
                                qnwyPercentageBrand.push(parseFloat((data.data.list[i].qnwyPercentage) || 0).toFixed(2));
                                tbwyPercentageBrand.push(parseFloat((data.data.list[i].jnwyExpenditurePercentage) || 0).toFixed(2));
                                deviceTypeSubNumBrand.push(data.data.list[i].deviceTypeSubNum || 0);
                                manufacturerNumBrand.push(data.data.list[i].manufacturerNum || 0);
                                hospitalNumBrand.push(data.data.list[i].hospitalNum || 0);
                                fullNameBrand.push(data.data.list[i].fullName || '');
                            }
                            sort('desc', jnAssetsAmountBrand, idsBrand, xAxisBrand, jnIncomeBrand, jnIncomeAssetsNumBrand, jnExpenditureBrand, jnExpenditureAssetsNumBrand, jnszPercentageBrand, qnIncomeBrand, qnIncomeAssetsNumBrand, qnExpenditureBrand, qnExpenditureAssetsNumBrand, qnszPercentageBrand, tbszPercentageBrand, jnwyPercentageBrand, qnAssetsAmountBrand, qnwyPercentageBrand, tbwyPercentageBrand, deviceTypeSubNumBrand, manufacturerNumBrand, hospitalNumBrand, fullNameBrand);
                        }
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                    setUlBrand('desc', 0);
                    if ((!$('#modal').is(':hidden')) && ($('#modal').attr('modal') == 'brand')) morebrands();

                    queryStatus.brand = true;
                    if (queryStatus.getStatus()) {
                        loading(true);
                        queryStatus.resetStatus();
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }

        function queryDeviceTop5Data() {
            idsDevice = [];
            xAxisDevice = [];
            departmentNameDevice = [];
            manufacturerDevice = [];
            snDevice = [];
            assetsNoDevice = [];
            jnIncomeDevice = [];
            qnIncomeDevice = [];
            tbsrPercentageDevice = [];
            jnExpenditureDevice = [];
            qnExpenditureDevice = [];
            tbzcPercentageDevice = [];
            jnszPercentageDevice = [];
            qnszPercentageDevice = [];
            jnAssetsAmountDevice = [];
            fullNameDevice = [];

            deviceJson = [];
            $.ajax({
                type: "POST",
                url: '<%=basePath%>/charts/hospital/hospital-cost/assets',
                data: {
                  hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd
                },
                dataType: "json",
                success: function (data) {
                    if (data.ret) {
                        data.data = data.data || {list: []};
                        deviceJson = (data.data.list || []).sortByKey('jnszPercentage').calTotal();
                        if (data.data.list) {
                            for (var i = 0; i < data.data.list.length; i++) {
                                idsDevice.push(data.data.list[i].id || '');
                                xAxisDevice.push(data.data.list[i].name || '');
                                departmentNameDevice.push(data.data.list[i].departmentName || '');
                                manufacturerDevice.push(data.data.list[i].manufacturer || '');
                                snDevice.push(data.data.list[i].sn || '');
                                assetsNoDevice.push(data.data.list[i].assetsNo || '');
                                jnIncomeDevice.push(parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2));
                                qnIncomeDevice.push(parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2));
                                tbsrPercentageDevice.push(parseFloat(data.data.list[i].tbsrPercentage || 0).toFixed(2));
                                jnExpenditureDevice.push(parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2));
                                qnExpenditureDevice.push(parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2));
                                tbzcPercentageDevice.push(parseFloat(data.data.list[i].tbzcPercentage || 0).toFixed(2));
                                jnszPercentageDevice.push(parseFloat(data.data.list[i].jnszPercentage || 0).toFixed(2));
                                qnszPercentageDevice.push(parseFloat(data.data.list[i].qnszPercentage || 0).toFixed(2));
                                jnAssetsAmountDevice.push(parseFloat((data.data.list[i].amount / CONST) || 0).toFixed(2));
                                fullNameDevice.push(data.data.list[i].name || '');
                            }
                        }
                        sort('desc', jnszPercentageDevice, idsDevice, xAxisDevice, departmentNameDevice, manufacturerDevice, snDevice, assetsNoDevice, jnIncomeDevice, qnIncomeDevice, tbsrPercentageDevice, jnExpenditureDevice, qnExpenditureDevice, tbzcPercentageDevice, qnszPercentageDevice, fullNameDevice);
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                    setUlDevice('desc', 0);
                    if ((!$('#modal').is(':hidden')) && ($('#modal').attr('modal') == 'device')) moredevices();

                    queryStatus.assets = true;
                    if (queryStatus.getStatus()) {
                        loading(true);
                        queryStatus.resetStatus();
                    }
                },
                failure: function (data) {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }


        $('#morehospitals').click(morehospitals);

        function morehospitals() {
            loading(function () {
                var modal = $('#modal').attr('modal', 'hospital');
                var sb = new StringBuffer();
                var table = $("#tblSort").html('<tbody></tbody>');
                var tbody = table.find('tbody');
                var data = hospitalJson;
                sb.append("<thead><tr><th class='text-center'>#</th>");
                //表头
                sb.append("<th class='text-left'><fmt:message key="share.table.head.yyks"/></th>");

                //表格内容
                sb.append("<th class='text-right'><fmt:message key="index.table.sbje(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.sr(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.srsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zc(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zcsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szb"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szbtb(%)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wysr"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wyzc"/></th>"
                    + "</tr></thead>");
                table.prepend(sb.toString());
                groupLoading(data.length, function (min, max) {
                    var str = '';
                    for (var i = min; i < max; i++) {
                        str += "<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick='query(\"hospital\",\"" + ids[i] + "\", \"" + (i + 1) + "\")'>" + xAxis[i] + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(jnAssetsAmount[i]).toFixed(2) + "</td>"
                            + "<td class='total-2 text-right'>" + parseFloat(jnIncome[i]).toFixed(2) + "</td>"
                            + "<td class='total-3 text-right"+(jnIncomeAssetsNum[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:3,departmentId:["+ids[i]+"]}')\">" + jnIncomeAssetsNum[i] + "</td>"
                            + "<td class='total-4 text-right'>" + parseFloat(jnExpenditure[i]).toFixed(2) + "</td>"
                            + "<td class='total-5 text-right"+(jnExpenditureAssetsNum[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:4,departmentId:["+ids[i]+"]}')\">" + jnExpenditureAssetsNum[i] + "</td>"
                            + "<td class='avg-6 text-right'>" + parseFloat(jnszPercentage[i]).toFixed(2) + "</td>"
                            + "<td class='avg-7 text-right yoy'>" + parseFloat(tbszPercentage[i]).toFixed(2) + "</td>"
                            + "<td class='avg-8 text-right'>" + parseFloat(jnwyPercentage[i]).toFixed(2) + "</td>"
                            + "<td class='avg-9 text-right'>" + parseFloat(tbwyPercentage[i]).toFixed(2) + "</td>"
                            + "</tr>";
                    }
                    tbody.append(str);
                    if (max === data.length)
                        calTableData('tblSort', true);
                });
                modal.iziModal('setTitle', '<fmt:message key="charts.title.yyksfb"/>');
                modal.iziModal('open', this);
                loading(true);
            });
        }

        $('#moredetail, #moretypes').click(moretypes);

        function moretypes(param) {
            loading(function () {
                param = $.extend({}, {
                    id: '',
                    dataJson: typeJson,
                    modal: 'modal',
                    table: 'tblSort'
                }, param);
                var modal = $('#' + param.modal).attr('modal', 'type');
                var sb = new StringBuffer();
                var table = $("#" + param.table).html('<tbody></tbody>');
                var tbody = table.find('tbody');
                var data = param.dataJson;
                sb.append("<thead><tr><th class='text-center'>#</th>");
                //表头
                sb.append("<th class='text-left'><fmt:message key="share.table.head.sbxh"/></th>");

                //表格内容
                sb.append("<th class='text-right'><fmt:message key="index.table.sbje(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.sr(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.srsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zc(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zcsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szb"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szbtb(%)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wysr"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wyzc"/></th>"
                    + "</tr></thead>");
                table.prepend(sb.toString());
                groupLoading(data.length, function (min, max) {
                    var str = '';
                    for (var i = min; i < max; i++) {
                        str += "<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick='query(\"type\",\"" + idsType[i] + "\")'>" + xAxisType[i] + "</td>"
                            + "<td class='total-0 text-right'>" + parseFloat(jnAssetsAmountType[i]).toFixed(2) + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(jnIncomeType[i]).toFixed(2) + "</td>"
                            + "<td class='total-2 text-right"+(jnIncomeAssetsNumType[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:3,monthId:"+param.id+",modelName:"+idsType[i]+"}')\">" + jnIncomeAssetsNumType[i] + "</td>"
                            + "<td class='total-3 text-right'>" + parseFloat(jnExpenditureType[i]).toFixed(2) + "</td>"
                            + "<td class='total-4 text-right"+(jnExpenditureAssetsNumType[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:4,monthId:"+param.id+",modelName:"+idsType[i]+"}')\">" + jnExpenditureAssetsNumType[i] + "</td>"
                            + "<td class='total-5text-right'>" + parseFloat(jnszPercentageType[i]).toFixed(2) + "</td>"
                            + "<td class='total-6 text-right yoy'>" + parseFloat(tbszPercentageType[i]).toFixed(2) + "</td>"
                            + "<td class='total-7 text-right'>" + parseFloat(jnwyPercentageType[i]).toFixed(2) + "</td>"
                            + "<td class='total-8 text-right'>" + parseFloat(tbwyPercentageType[i]).toFixed(2) + "</td>"
                            + "</tr>";
                    }
                    tbody.append(str);
                    if (max === data.length)
                        calTableData(param.table, true);
                });
                modal.iziModal('setTitle', '<fmt:message key="charts.title.sbxhfb"/>');
                modal.iziModal('open', this);
                loading(true);
            });
        }

        $('#morebrand').click(morebrands);

        function morebrands() {
            loading(function () {
                var modal = $('#modal').attr('modal', 'brand');
                var sb = new StringBuffer();
                var table = $("#tblSort").html('<tbody></tbody>');
                var tbody = table.find('tbody');
                var data = brandJson;
                sb.append("<thead><tr><th class='text-center'>#</th>");
                //表头
                sb.append("<th class='text-left'><fmt:message key="share.table.head.sbcj"/></th>");

                //表格内容
                sb.append("<th class='text-right'><fmt:message key="index.table.sbje(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.sr(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.srsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zc(wy)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.zcsbs(t)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szb"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.szbtb(%)"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wysr"/></th>"
                    + "<th class='text-right'><fmt:message key="performance.table.wyzc"/></th>"
                    + "</tr></thead>");
                table.prepend(sb.toString());
                groupLoading(data.length, function (min, max) {
                    var str = '';
                    for (var i = min; i < max; i++) {
                        str += "<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick='query(\"brand\",\"" + idsBrand[i] + "\")'>" + xAxisBrand[i] + "</td>"
                            + "<td class='total-0 text-right'>" + parseFloat(jnAssetsAmountBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(jnIncomeBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-2 text-right"+(jnIncomeAssetsNumBrand[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:3,brandId:["+idsBrand[i]+"]}')\">" + jnIncomeAssetsNumBrand[i] + "</td>"
                            + "<td class='total-3 text-right'>" + parseFloat(jnExpenditureBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-4 text-right"+(jnExpenditureAssetsNumBrand[i]?' spanTitle':'')+"' onclick=\"queryDeviceTable('{queryType:4,brandId:["+idsBrand[i]+"]}')\">" + jnExpenditureAssetsNumBrand[i] + "</td>"
                            + "<td class='total-5 text-right'>" + parseFloat(jnszPercentageBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-6 text-right yoy'>" + parseFloat(tbszPercentageBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-7 text-right'>" + parseFloat(jnwyPercentageBrand[i]).toFixed(2) + "</td>"
                            + "<td class='total-8 text-right'>" + parseFloat(tbwyPercentageBrand[i]).toFixed(2) + "</td>"
                            + "</tr>";
                    }
                    tbody.append(str);
                    if (max === data.length)
                        calTableData("tblSort", true);
                });
                modal.iziModal('setTitle', '<fmt:message key="share.table.title.sbcjfbxq"/>');
                modal.iziModal('open', this);
                loading(true);
            });
        }

        $('#moredevices').click(moredevices);

        function moredevices() {
            loading(function () {
                var modal = $('#modal').attr('modal', 'device');
                var sb = new StringBuffer();
                var table = $("#tblSort").html('<tbody></tbody>');
                var tbody = table.find('tbody');
                var data = deviceJson;
                sb.append("<thead><tr><th class='text-center' key='' value='<fmt:message key="share.table.tail.zj"/>'>#</th>");
                //表头
                sb.append("<th class='text-left' key='name'><fmt:message key="share.table.head.sbmc"/></th>");

                //表格内容
                sb.append("<th class='text-left' key='firstTypeName'><fmt:message key="share.title.sblx"/></th>"
                    + "<th class='text-left' key='departmentName'><fmt:message key="share.assets.ssks"/></th>"
                    + "<th class='text-left' key='manufacturer'><fmt:message key="share.table.head.sbcj"/></th>"
                    + "<th class='text-left' key='sn' value=''><fmt:message key="share.assets.snbh"/></th>"
                    + "<th class='text-left' key='assetsNo' value=''><fmt:message key="share.assets.zcbh"/></th>"
                    + "<th class='text-right' key='amount' value='" + fix2(data[-1].amount / CONST) + "'><fmt:message key="share.assets.sbje(wy)"/></th>"
                    + "<th class='text-right key='jnIncome' value='" + fix2(data[-1].jnIncome / CONST) + "''><fmt:message key="performance.assets.jnsr(wy)"/></th>"
                    + "<th class='text-right key='qnIncome' value='" + fix2(data[-1].qnIncome / CONST) + "''><fmt:message key="performance.assets.qnsr(wy)"/></th>"
                    + "<th class='text-right key='tbsrPercentage' value='" + fix2(data[-1].tbsrPercentage / data.length) + "''><fmt:message key="performance.assets.srtb(%)"/></th>"
                    + "<th class='text-right key='jnExpenditure' value='" + fix2(data[-1].jnExpenditure / CONST) + "''><fmt:message key="performance.assets.jnzc(wy)"/></th>"
                    + "<th class='text-right key='qnExpenditure' value='" + fix2(data[-1].qnExpenditure / CONST) + "''><fmt:message key="performance.assets.qnzc(wy)"/></th>"
                    + "<th class='text-right key='tbzcPercentage' value='" + fix2(data[-1].tbzcPercentage / data.length) + "''><fmt:message key="performance.assets.zctb(%)"/></th>"
                    + "<th class='text-right key='jnszPercentage' value='" + fix2(data[-1].jnszPercentage / data.length) + "''><fmt:message key="performance.assets.jnszb(%)"/></th>"
                    + "<th class='text-right key='qnszPercentage' value='" + fix2(data[-1].qnszPercentage / data.length) + "''><fmt:message key="performance.assets.qnszb(%)"/></th>"
                    + "</tr></thead>");
                table.prepend(sb.toString());
                groupLoading(data.length, function (min, max) {
                    var str = '';
                    for (var i = min; i < max; i++) {
                        str += "<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal spanTitle' onclick='query(\"device\",\"" + idsDevice[i] + "\")' title='" + xAxisDevice[i] + "'>" + xAxisDevice[i] + "</td>"
                            + "<td class='no-cal'>" + fixStr(data[i].firstTypeName) + "</td>"
                            + "<td class='no-cal text-left'>" + departmentNameDevice[i] + "</td>"
                            + "<td class='no-cal' title='" + manufacturerDevice[i] + "'>" + manufacturerDevice[i] + "</td>"
                            + "<td class='no-cal text-left'>" + snDevice[i] + "</td>"
                            + "<td class='no-cal text-left' title='" + assetsNoDevice[i] + "'>" + assetsNoDevice[i] + "</td>"
                            + "<td class='total-0 text-right'>" + fix2(data[i].amount / CONST) + "</td>"
                            + "<td class='total-1 text-right'>" + jnIncomeDevice[i] + "</td>"
                            + "<td class='total-2 text-right'>" + qnIncomeDevice[i] + "</td>"
                            + "<td class='avg-1 text-right yoy'>" + tbsrPercentageDevice[i] + "</td>"
                            + "<td class='total-3 text-right'>" + jnExpenditureDevice[i] + "</td>"
                            + "<td class='total-4 text-right'>" + qnExpenditureDevice[i] + "</td>"
                            + "<td class='avg-2 text-right yoy'>" + tbzcPercentageDevice[i] + "</td>"
                            + "<td class='avg-3 text-right'>" + jnszPercentageDevice[i] + "</td>"
                            + "<td class='avg-4 text-right'>" + qnszPercentageDevice[i] + "</td>"
                            + "</tr>";
                    }
                    tbody.append(str);
                    if (max === data.length)
                        calTableData('tblSort', true);
                });
                modal.iziModal('setTitle', '<fmt:message key="share.table.title.sbfbxq"/>');
                modal.iziModal('open', this);
                loading(true);
            });
        }

        function query(tag, id, detailId) {
            if (detailId) {
                if (tag == 'type') {
                    modelName = id;
                    queryDeviceData(detailId);
                }
            } else if (tag == 'hospital') {
                location.href = '<%=basePath%>/charts/hospital/type-index/page?departmentId=' + id + '&hospitalId=' + hspId;
            } else if (tag == 'type') {
                queryDeviceTable('{modelName:'+id+'}')
            } else if (tag == 'brand') {
                location.href = '<%=basePath%>/charts/hospital/type-brand/page?brandId=' + id + '&hospitalId=' + hspId;
            } else if (tag == 'device' && deviceRedirect) {
                window.open('<%=basePath%>/charts/overview/assets/page?deviceId=' + id);
            } else if (tag === 'year') {
                publicAjax('<%=basePath%>/charts/hospital/hospital-cost/model', 'post', {
                    hospitalId: hspId,
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: id,
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd
                }, function (data) {
                    if (data.ret && data.data && data.data.list) {
                        typeYear = (data.data.list || []).sortByKey('jnAssetsAmount').calTotal();
                    } else {
                        typeYear = [];
                    }
                    moretypes({
                        id: id,
                        dataJson: typeYear,
                        modal: 'typeModal',
                        table: 'typeTable'
                    });
                });
            }
        }

        // 通过设备型号查找设备(设备类型)
        function queryDeviceData(detailId) {
            if ($(".detail-tr-" + detailId).hasClass("hide")) {
                $(".detail-tr-" + detailId).removeClass("hide");
                $("#detail-" + detailId).removeClass("fa-plus");
                $("#detail-" + detailId).addClass("fa-minus");
                $.ajax({
                    type: "POST",
                    url: '<%=basePath%>/charts/hospital/hospital-cost/device',
                    data: {
                      hospitalId: hspId,
                        riskId: riskId ? JSON.stringify(riskId) : '',
                        departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                        typeId: typeId ? JSON.stringify(typeId) : '',
                        modelName: modelName || '',
                        brandId: brandId ? JSON.stringify(brandId) : '',
                        year: year ? JSON.stringify(year) : '',
                        monthId: monthId ? JSON.stringify(monthId) : '',
                        enableYearStart: enableYearStart,
                        enableYearEnd: enableYearEnd,
                        priceStart: priceStart,
                        priceEnd: priceEnd,
                        ageLimitStart: ageLimitStart,
                        ageLimitEnd: ageLimitEnd,
                        queryType: type + 2,
                        queryMax: queryMaxValue,
                        queryMin: queryMinValue
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.ret == 1) {
                            data.data = data.data || {list: []};
                            if (data.data.list) {
                                var sb = new StringBuffer();
                                $("#detail-table-" + detailId).html('<tbody id="table_data"></tbody>');
                                sb.append("<thead><tr><th class='text-center'>#</th>");
                                //表头
                                sb.append("<th class='text-left'><fmt:message key="share.table.head.sbmc"/></th>");

                                //表格内容
                                sb.append("<th class='text-left'><fmt:message key="share.assets.ssks"/></th>"
                                    + "<th class='text-left'><fmt:message key="share.assets.snbh"/></th>"
                                    + "<th class='text-left'><fmt:message key="share.assets.zcbh"/></th>"
                                    + "<th class='text-left'><fmt:message key="share.table.head.sbcj"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.jnsr(wy)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.qnsr(wy)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.srtb(%)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.jnzc(wy)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.qnzc(wy)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.zctb(%)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.jnszb(%)"/></th>"
                                    + "<th class='text-right'><fmt:message key="performance.assets.qnszb(%)"/></th>"
                                    + "</tr></thead>");
                                $("#detail-table-" + detailId).prepend(sb.toString());
                                for (var i = 0; i < data.data.list.length; i++) {
                                    $("#detail-table-" + detailId + " tbody").append("<tr>"
                                        + "<td class='text-center'>" + (i + 1) + "</td>"
                                        + "<td class='spanTitle' onclick=query(\"device\",\"" + data.data.list[i].id + "\") title='" + (data.data.list[i].name || '') + "'>" + (data.data.list[i].name || '') + "</td>"
                                        + "<td class='text-left'>" + (data.data.list[i].departmentName || '') + "</td>"
                                        + "<td class='text-left'>" + (data.data.list[i].sn || '') + "</td>"
                                        + "<td class='text-left' title='" + (data.data.list[i].assetsNo || '') + "'>" + (data.data.list[i].assetsNo || '') + "</td>"
                                        + "<td class='text-right'>" + (data.data.list[i].manufacturer || '') + "</td>"
                                        + "<td class='text-right'>" + parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right'>" + parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right yoy'>" + parseFloat(data.data.list[i].tbsrPercentage || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right'>" + parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right'>" + parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right yoy'>" + parseFloat(data.data.list[i].tbzcPercentage || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right'>" + parseFloat(data.data.list[i].jnszPercentage || 0).toFixed(2) + "</td>"
                                        + "<td class='text-right'>" + parseFloat(data.data.list[i].jnszPercentage || 0).toFixed(2) + "</td>"
                                        + "</tr>");
                                }

                            } else {
                                $("#detail-table-" + detailId).html('<p><fmt:message key="share.talbe.myxgjl"/></p>');
                            }
                        } else {
                            flavrShowByTime(data.msg, null, "danger", false);
                        }
                    },
                    failure: function () {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                })
            } else {
                $(".detail-tr-" + detailId).addClass("hide");
                $("#detail-" + detailId).addClass("fa-plus");
                $("#detail-" + detailId).removeClass("fa-minus");
            }
        }

        function queryDeviceTable(param) {
            param = string2json(param) || {};
            $.ajax({
                type: "POST",
                url: '<%=basePath%>/charts/hospital/hospital-cost/device',
                data: $.extend({}, {
                  hospitalId: hspId,
                    riskId: riskId ? JSON.stringify(riskId) : '',
                    departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                    typeId: typeId ? JSON.stringify(typeId) : '',
                    brandId: brandId ? JSON.stringify(brandId) : '',
                    year: year ? JSON.stringify(year) : '',
                    monthId: monthId ? JSON.stringify(monthId) : '',
                    enableYearStart: enableYearStart,
                    enableYearEnd: enableYearEnd,
                    priceStart: priceStart,
                    priceEnd: priceEnd,
                    ageLimitStart: ageLimitStart,
                    ageLimitEnd: ageLimitEnd,
                    queryType: type + 2,
                    queryMax: queryMaxValue,
                    queryMin: queryMinValue
                }, param),
                dataType: "json",
                success: function (data) {
                    if (data.ret) {
                        data.data = data.data || {list: []};
                        if (data.data.list) {
                            var sb = new StringBuffer();
                            sb.append("<tr><th class='text-center'>#</th>");
                            //表头
                            sb.append("<th class='text-left'><fmt:message key="share.table.head.sbmc"/></th>");

                            //表格内容
                            sb.append("<th class='text-left'><fmt:message key="share.assets.ssks"/></th>"
                                + "<th class='text-left'><fmt:message key="share.assets.snbh"/></th>"
                                + "<th class='text-left'><fmt:message key="share.assets.zcbh"/></th>"
                                + "<th class='text-left'><fmt:message key="share.table.head.sbcj"/></th>"
                                + "<th class='text-right'><fmt:message key="share.assets.sbje(wy)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.jnsr(wy)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.qnsr(wy)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.srtb(%)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.jnzc(wy)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.qnzc(wy)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.zctb(%)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.jnszb(%)"/></th>"
                                + "<th class='text-right'><fmt:message key="performance.assets.qnszb(%)"/></th>"
                                + "</tr>");
                            var str = '';
                            for (var i = 0; i < data.data.list.length; i++) {
                                str += "<tr>"
                                    + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                                    + "<td class='no-cal spanTitle' onclick=query(\"device\",\"" + data.data.list[i].id + "\") title='" + (data.data.list[i].name || '') + "'>" + (data.data.list[i].name || '') + "</td>"
                                    + "<td class='no-cal text-left' title='" + (data.data.list[i].departmentName || '') + "'>" + (data.data.list[i].departmentName || '') + "</td>"
                                    + "<td class='no-cal text-left' title='" + (data.data.list[i].sn || '') + "'>" + (data.data.list[i].sn || '') + "</td>"
                                    + "<td class='no-cal text-left' title='" + (data.data.list[i].assetsNo || '') + "'>" + (data.data.list[i].assetsNo || '') + "</td>"
                                    + "<td class='no-cal text-left'>" + (data.data.list[i].manufacturer || '') + "</td>"
                                    + "<td class='total-0 text-right'>" + fix2(data.data.list[i].amount/CONST) + "</td>"
                                    + "<td class='total-1 text-right'>" + parseFloat((data.data.list[i].jnIncome / CONST) || 0).toFixed(2) + "</td>"
                                    + "<td class='total-2 text-right'>" + parseFloat((data.data.list[i].qnIncome / CONST) || 0).toFixed(2) + "</td>"
                                    + "<td class='avg-3 text-right yoy'>" + parseFloat(data.data.list[i].tbsrPercentage || 0).toFixed(2) + "</td>"
                                    + "<td class='total-4 text-right'>" + parseFloat((data.data.list[i].jnExpenditure / CONST) || 0).toFixed(2) + "</td>"
                                    + "<td class='total-5 text-right'>" + parseFloat((data.data.list[i].qnExpenditure / CONST) || 0).toFixed(2) + "</td>"
                                    + "<td class='avg-6 text-right yoy'>" + parseFloat(data.data.list[i].tbzcPercentage || 0).toFixed(2) + "</td>"
                                    + "<td class='avg-7 text-right'>" + parseFloat(data.data.list[i].jnszPercentage || 0).toFixed(2) + "</td>"
                                    + "<td class='avg-8 text-right'>" + parseFloat(data.data.list[i].jnszPercentage || 0).toFixed(2) + "</td>"
                                    + "</tr>";
                            }
                            addAssetModal('<fmt:message key="share.talbe.sbxq"/>', sb.toString(), str);
                        }
                    } else {
                        flavrShowByTime(data.msg, null, "danger", false);
                    }
                },
                failure: function () {
                    flavrShowByTime(data.msg, null, "danger", false);
                }
            })
        }

        // 历年数据点击事件
        $('#overyear').click(function () {
            if ($(this).hasClass('active')) {
                $('#moredetail').html('<fmt:message key="charts.title.sbxhfb"/>').off().on('click', moretypes);
                $(this).html('<fmt:message key="charts.button.yfxs"/>').removeClass('active');
                showYearTop5();
                chart.clear();
                chart.setOption(optionAgelimit);
                $('.quadrantContainner').show();
                $('.quadrant').removeClass('active');
                $('#tag').next().show();
            } else {
                $(this).html('<fmt:message key="charts.button.qbxs"/>').addClass('active');
                $('.quadrantContainner').hide();
                $('#tag').next().hide();
                showYearTop5(true);
                loading(function () {
                    $('#moredetail').html('<fmt:message key="share.table.title.yffb"/>').off().on('click', moreyear);
                    xAxisB = [];
                    idsB = [];
                    totalIncomeB = [];      //总收入
                    totalExpenditureB = []; //总支出
                    szPercentageB = [];     //收支比
                    lastTotalIncomeB = [];
                    lastTotalExpenditureB = [];
                    lastSzPercentageB = [];
                    $("#ul_year").html('');
                    yearJson = [];
                    $.ajax({
                        url: '<%=basePath%>/charts/hospital/hospital-cost/month-trend',
                        data: {
                          hospitalId: hspId,
                            departmentId: hospitalId ? JSON.stringify(hospitalId) : '',
                            riskId: riskId ? JSON.stringify(riskId) : '',
                            typeId: typeId ? JSON.stringify(typeId) : '',
                            brandId: brandId ? JSON.stringify(brandId) : '',
                            year: year ? JSON.stringify(year) : '',
                            monthId: monthId ? JSON.stringify(monthId) : '',
                            enableYearStart: enableYearStart,
                            enableYearEnd: enableYearEnd,
                            priceStart: priceStart,
                            priceEnd: priceEnd,
                            ageLimitStart: ageLimitStart,
                            ageLimitEnd: ageLimitEnd,
                            queryType: type + 2,
                            queryMax: queryMaxValue,
                            queryMin: queryMinValue
                        },
                        type: 'post',
                        success: function (data) {
                            if (data.ret == 1) {
                                data.data = data.data || {list: []};
                                yearJson = data.data.thisYearData.calTotal();
                                for (var i = 0; i < data.data.thisYearData.length; i++) {
                                    xAxisB.push(data.data.thisYearData[i].monthName);
                                    idsB.push(data.data.thisYearData[i].month);
                                    // 今年
                                    totalIncomeB.push(parseFloat((data.data.thisYearData[i].totalIncome / CONST) || 0).toFixed(2));
                                    totalExpenditureB.push(parseFloat((data.data.thisYearData[i].totalExpenditure / CONST) || 0).toFixed(2));
                                    szPercentageB.push(parseFloat(data.data.thisYearData[i].szPercentage || 0).toFixed(2));
                                    // 去年
                                    lastTotalIncomeB.push(parseFloat((data.data.lastYearData[i].totalIncome / CONST) || 0).toFixed(2));
                                    lastTotalExpenditureB.push(parseFloat((data.data.lastYearData[i].totalExpenditure / CONST) || 0).toFixed(2));
                                    lastSzPercentageB.push(parseFloat(data.data.lastYearData[i].szPercentage || 0).toFixed(2));

                                    if (type == 0) {
                                        $("#ul_year").append(
                                            '<li><a><span class="fl data_span_f">' + data.data.thisYearData[i].monthName + '</span><em class="fr">'
                                            + parseFloat(data.data.thisYearData[i].szPercentage || 0).toFixed(2) + '</em></a></li>');
                                    } else if (type == 1) {
                                        $("#ul_year").append(
                                            '<li><a><span class="fl data_span_f">' + data.data.thisYearData[i].monthName + '</span><em class="fr">'
                                            + parseFloat((data.data.thisYearData[i].totalIncome / CONST) || 0).toFixed(2) + '</em></a></li>');
                                    } else if (type == 2) {
                                        $("#ul_year").append(
                                            '<li><a><span class="fl data_span_f">' + data.data.thisYearData[i].monthName + '</span><em class="fr">'
                                            + parseFloat((data.data.thisYearData[i].totalExpenditure / CONST) || 0).toFixed(2) + '</em></a></li>');
                                    }
                                }
                                expendYoyB = data.data.expendYoy;
                                incomeYoyB = data.data.incomeYoy;
                                szPercentageYoyB = data.data.szPercentageYoy;

                                optionB.xAxis.data = xAxisB;
                                if (type == 0) {
                                    optionB.legend.data = ['<fmt:message key="performance.table.szb"/>', '<fmt:message key="performance.legend.szbtb"/>'];
                                    optionB.yAxis = {
                                        name: '%',
                                        type: 'value',
                                        nameTextStyle: {
                                            color: '#AAA',
                                            fontSize: 0.28 * rem
                                        },
                                        splitLine: {
                                            lineStyle: {
                                                type: 'dashed'
                                            }
                                        },
                                        axisLabel: {
                                            fontSize: 0.28 * rem
                                        }
                                    };
                                    optionB.series = [{
                                        name: '<fmt:message key="performance.table.szb"/>',
                                        type: 'line',
                                        data: szPercentageB
                                    }, {
                                        name: '<fmt:message key="performance.legend.szbtb"/>',
                                        type: 'line',
                                        data: szPercentageYoyB
                                    }];
                                } else if (type == 1) {
                                    optionB.legend.data = ['<fmt:message key="performance.overview.sr"/>', '<fmt:message key="performance.legend.qnsr"/>', '<fmt:message key="performance.legend.srtb"/>'];
                                    optionB.yAxis = [{
                                        name: '<fmt:message key="share.unit.wanyuan"/>',
                                        type: 'value',
                                        nameTextStyle: {
                                            color: '#AAA',
                                            fontSize: 0.28 * rem
                                        },
                                        splitLine: {
                                            lineStyle: {
                                                type: 'dashed'
                                            }
                                        },
                                        axisLabel: {
                                            fontSize: 0.28 * rem
                                        }
                                    }, {
                                        name: '%',
                                        type: 'value',
                                        nameTextStyle: {
                                            color: '#AAA',
                                            fontSize: 0.28 * rem
                                        },
                                        splitLine: {
                                            show: false,
                                            lineStyle: {
                                                type: 'dashed'
                                            }
                                        },
                                        axisLabel: {
                                            fontSize: 0.28 * rem
                                        }
                                    }];
                                    optionB.series = [{
                                        name: '<fmt:message key="performance.overview.sr"/>',
                                        type: 'bar',
                                        barMaxWidth: barMaxWidth,
                                        barGap: '0%',
                                        data: totalIncomeB
                                    }, {
                                        name: '<fmt:message key="performance.legend.qnsr"/>',
                                        type: 'bar',
                                        barMaxWidth: barMaxWidth,
                                        data: lastTotalIncomeB
                                    }, {
                                        name: '<fmt:message key="performance.legend.srtb"/>',
                                        type: 'line',
                                        data: incomeYoyB,
                                        yAxisIndex: 1
                                    }];
                                } else if (type == 2) {
                                    optionB.legend.data = ['<fmt:message key="performance.overview.zc"/>', '<fmt:message key="performance.legend.qnzc"/>', '<fmt:message key="performance.legend.zctb"/>'];
                                    optionB.yAxis = [{
                                        name: '<fmt:message key="share.unit.wanyuan"/>',
                                        type: 'value',
                                        nameTextStyle: {
                                            color: '#AAA',
                                            fontSize: 0.28 * rem
                                        },
                                        splitLine: {
                                            lineStyle: {
                                                type: 'dashed'
                                            }
                                        },
                                        axisLabel: {
                                            fontSize: 0.28 * rem
                                        }
                                    }, {
                                        name: '%',
                                        type: 'value',
                                        nameTextStyle: {
                                            color: '#AAA',
                                            fontSize: 0.28 * rem
                                        },
                                        splitLine: {
                                            show: false,
                                            lineStyle: {
                                                type: 'dashed'
                                            }
                                        },
                                        axisLabel: {
                                            fontSize: 0.28 * rem
                                        }
                                    }];
                                    optionB.series = [{
                                        name: '<fmt:message key="performance.overview.zc"/>',
                                        type: 'bar',
                                        barMaxWidth: barMaxWidth,
                                        barGap: '0%',
                                        data: totalExpenditureB
                                    }, {
                                        name: '<fmt:message key="performance.legend.qnzc"/>',
                                        type: 'bar',
                                        barMaxWidth: barMaxWidth,
                                        data: lastTotalExpenditureB
                                    }, {
                                        name: '<fmt:message key="performance.legend.zctb"/>',
                                        type: 'line',
                                        data: expendYoyB,
                                        yAxisIndex: 1
                                    }];
                                }
                                chart.clear();
                                chart.setOption(optionB);
                            } else {
                                flavrShowByTime(data.msg, null, "danger", false);
                            }
                            loading(true);
                        },
                        failure: function (data) {
                            flavrShowByTime(data.msg, null, "danger", false);
                        }
                    });
                });
            }
        });

        function moreyear() {
            loading(function () {
                var sb = new StringBuffer();
                var modal = $('#modal').attr('modal', 'year');
                var table = $("#tblSort").html('<tbody></tbody>');
                var tbody = table.find('tbody');
                sb.append("<thead><tr><th class='text-center'>#</th>");
                //表头
                sb.append("<th class='text-left'><fmt:message key="share.table.head.yf"/></th>");

                //表格内容
                if (type == 0) {
                    sb.append("<th class='text-right'><fmt:message key="performance.table.szb"/></th>"
                        + "<th class='text-right'><fmt:message key="performance.table.szbtb(%)"/></th>"
                        + "</tr></thead>");
                    table.prepend(sb.toString());
                    for (var i = 0; i < xAxisB.length; i++) {
                        tbody.append("<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick=\"query('year','" + idsB[i] + "')\">" + xAxisB[i] + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(szPercentageB[i]).toFixed(2) + "</td>"
                            + "<td class='total-3 text-right yoy'>" + parseFloat(szPercentageYoyB[i]).toFixed(2) + "</td>"
                            + "</tr>");
                    }
                } else if (type == 1) {
                    sb.append("<th class='text-right'><fmt:message key="performance.table.sr(wy)"/></th>"
                        + "<th class='text-right'><fmt:message key="performance.assets.qnsr(wy)"/></th>"
                        + "<th class='text-right'><fmt:message key="performance.assets.srtb(%)"/></th>"
                        + "</tr></thead>");
                    table.prepend(sb.toString());
                    for (var i = 0; i < xAxisB.length; i++) {
                        tbody.append("<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick=\"query('year','" + idsB[i] + "')\">" + xAxisB[i] + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(totalIncomeB[i]).toFixed(2) + "</td>"
                            + "<td class='total-3 text-right'>" + parseFloat(lastTotalIncomeB[i]).toFixed(2) + "</td>"
                            + "<td class='avg-5 text-right yoy'>" + parseFloat(incomeYoyB[i]).toFixed(2) + "</td>"
                            + "</tr>");
                    }
                } else if (type == 2) {
                    sb.append("<th class='text-right'><fmt:message key="performance.table.zc(wy)"/></th>"
                        + "<th class='text-right'><fmt:message key="performance.assets.qnzc(wy)"/></th>"
                        + "<th class='text-right'><fmt:message key="performance.assets.zctb(%)"/></th>"
                        + "</tr></thead>");
                    table.prepend(sb.toString());
                    for (var i = 0; i < xAxisB.length; i++) {
                        tbody.append("<tr>"
                            + "<td class='no-cal text-center'>" + (i + 1) + "</td>"
                            + "<td class='no-cal text-left spanTitle' onclick=\"query('year','" + idsB[i] + "')\">" + xAxisB[i] + "</td>"
                            + "<td class='total-1 text-right'>" + parseFloat(totalExpenditureB[i]).toFixed(2) + "</td>"
                            + "<td class='total-3 text-right'>" + parseFloat(lastTotalExpenditureB[i]).toFixed(2) + "</td>"
                            + "<td class='avg-5 text-right yoy'>" + parseFloat(expendYoyB[i]).toFixed(2) + "</td>"
                            + "</tr>");
                    }
                }
                calTableData("tblSort", true);
                modal.iziModal('setTitle', '<fmt:message key="share.table.title.yffb"/>');
                modal.iziModal('open', this);
                loading(true);
            });
        }


        // 柱状 + 折线  历年数据Option
        var optionB = {
            color: ['#2089ff', '#6c63ff', '#12a0df', '#fb8a22', '#fef534'],
            backgroundColor: '#373945',
            tooltip: {
                trigger: 'axis',
                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                },
                textStyle: {
                    fontSize: 0.28 * rem
                },
                formatter: function (a) {
                    if (a.componentType == "markLine") {
                        return a.name + ':' + a.value;
                    } else {
                        var index = a[0].dataIndex;
                        if (type == 0) {
                            return xAxisB[index] + '<br/>'
                                + '<fmt:message key="performance.overview.szb"/>：' + szPercentageB[index] + '<br/>'
                                + '<fmt:message key="performance.legend.szbtb"/>：' + parseFloat(szPercentageYoyB[index]).toFixed(2) + '%';
                        } else if (type == 1) {
                            return xAxisB[index] + '<br/>'
                                + '<fmt:message key="performance.overview.sr"/>：' + totalIncomeB[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                                + '<fmt:message key="performance.legend.qnsr"/>：' + lastTotalIncomeB[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                                + '<fmt:message key="performance.legend.srtb"/>：' + parseFloat(incomeYoyB[index]).toFixed(2) + '%';
                        } else if (type == 2) {
                            return xAxisB[index] + '<br/>'
                                + '<fmt:message key="performance.overview.zc"/>：' + totalExpenditureB[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                                + '<fmt:message key="performance.legend.qnzc"/>：' + lastTotalExpenditureB[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                                + '<fmt:message key="performance.legend.zctb"/>：' + parseFloat(expendYoyB[index]).toFixed(2) + '%';
                        }
                    }
                }
            },
            legend: {
                x: "right",
                textStyle: {
                    color: '#AAA',
                    fontSize: 0.28 * rem
                },
                data: ['<fmt:message key="performance.overview.zsr"/>', '<fmt:message key="performance.overview.zzc"/>', '<fmt:message key="performance.overview.szb"/>']
            },
            grid: {
                top: 1.2 * rem,
                left: 0.4 * rem,
                right: 0.4 * rem,
                bottom: 0.8 * rem,
                containLabel: true
            },
            xAxis: {
                type: 'category',
                data: [],
                axisLabel: {
                    rotate: 30,
                    fontSize: 0.28 * rem
                }
            },
            yAxis: [{
                name: '<fmt:message key="share.unit.wanyuan"/>',
                type: 'value',
                nameTextStyle: {
                    color: '#AAA',
                    fontSize: 0.28 * rem
                },
                splitLine: {
                    lineStyle: {
                        type: 'dashed'
                    }
                },
                axisLabel: {
                    fontSize: 0.28 * rem
                }
            }, {
                name: '%',
                type: 'value',
                nameTextStyle: {
                    color: '#AAA',
                    fontSize: 0.28 * rem
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        type: 'dashed'
                    }
                },
                axisLabel: {
                    fontSize: 0.28 * rem
                }
            }],
            series: [{
                name: '<fmt:message key="performance.overview.zsr"/>',
                type: 'bar',
                barMaxWidth: barMaxWidth,
                barGap: '0%',
                data: []
            }, {
                name: '<fmt:message key="performance.overview.zzc"/>',
                type: 'bar',
                barMaxWidth: barMaxWidth,
                data: []
            }, {
                name: '<fmt:message key="performance.overview.szb"/>',
                type: 'line',
                data: [],
                yAxisIndex: 1
            }]
        };

        //设备年限气泡图
        var optionAgelimit = {
            color: ['#31860f'],
            backgroundColor: '#373945',
            tooltip: {
                trigger: 'item',
                textStyle: {
                    fontSize: 0.28 * rem
                },
                formatter: function (a) {
                    if (a.componentType == "markLine") {
                        return a.name + ':' + a.value;
                    } else {
                        var index = a.dataIndex;
                        return xAxisType[index] + '<br/>'
                            + '<fmt:message key="performance.overview.sr"/>：' + jnIncomeType[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                            + '<fmt:message key="performance.overview.zc"/>：' + jnExpenditureType[index] + '<fmt:message key="share.unit.wanyuan"/><br/>'
                            + '<fmt:message key="performance.overview.szb"/>：' + jnszPercentageType[index] + '';
                    }
                }
            },
            dataZoom: [{
                type: 'inside',
                xAxisIndex: [0],
                start: 0,
                end: 100
            },
                {
                    type: 'inside',
                    yAxisIndex: [0],
                    start: 0,
                    end: 100
                }
            ],
            grid: {
                top: 1.2 * rem,
                left: 0.4 * rem,
                right: 2.4 * rem,
                bottom: 0.8 * rem,
                containLabel: true
            },
            xAxis: {
                name: '<fmt:message key="charts.axis.sbje-wy"/>',
                type: 'value',
                nameTextStyle: {
                    color: '#AAA',
                    fontSize: 0.28 * rem
                },
                axisLabel: {
                    show: true,
                    fontSize: 0.28 * rem,
                    textStyle: {
                        color: '#fff'
                    }
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        color: '#f00',
                        type: 'dashed'
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisTick: {
                    lineStyle: {
                        color: '#fff'
                    }
                }
            },
            yAxis: [{
                name: '<fmt:message key="performance.overview.szb"/>',
                type: 'value',
                nameTextStyle: {
                    color: '#AAA',
                    fontSize: 0.28 * rem
                },
                axisLabel: {
                    show: true,
                    fontSize: 0.28 * rem,
                    textStyle: {
                        color: '#fff'
                    }
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        color: '#f00',
                        type: 'dashed'
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisTick: {
                    lineStyle: {
                        color: '#fff'
                    }
                }
            }],
            series: [{
                type: 'scatter',
                data: [],
                symbolSize: function (data) {
                    if (data[2] === 0) return 0;
                    return 35;
                },
                markLine: {
                    lineStyle: {
                        normal: {
                            color: '#f00',
                            type: 'dashed',
                            opacity: 0.4
                        }
                    },
                    data: [
                        {
                            type: 'average',
                            name: '<fmt:message key="charts.avg.sbjepjz(wy)"/>',
                            valueIndex: 0,
                            xAxis: null
                        },
                        {type: 'average', name: '<fmt:message key="charts.axis.szbpjz(%)"/>', valueIndex: 1, yAxis: null}
                    ]
                }
            }]
        };
    </script>
    </body>
</fmt:bundle>
</html>
